package June.ploy;

public class PloyArray {
    public static void main(String[] args) {
        Person[] persons = new Person[5];
        persons[0] = new Person( "jack", 5);
        persons[1] = new Student("marry",18,100);
        persons[2] = new Student("king",20,59.99);
        persons[3] = new Teacher("Li",30,10000.1);
        persons[4] = new Teacher("Wang",50,20000);

        for(int i = 0; i < persons.length; i++) {
            System.out.println(persons[i].say());
            if (persons[i] instanceof Student) {
                ((Student) persons[i]).study();
            } else if (persons[i] instanceof Teacher) {
                ((Teacher) persons[i]).teach();
            } else if (persons[i] instanceof Person) {

            } else {
                System.out.println("你的输入类型有误！");
            }
        }

    }
}
